package com.sufen.common.reponse;

import org.aspectj.apache.bcel.classfile.Code;

/**
 * @description:
 * @function:
 * @author: Liu Menglei
 * @Date: 2021/11/1 0001 21:23
 */
public class CodeMsg {

    private int code;
    private String msg;

    //通用错误码
    public static  CodeMsg SUCCESS = new  CodeMsg(0,"Success");
    public static  CodeMsg SERVER_ERROR = new  CodeMsg(50100,"服务端异常");
    public static  CodeMsg BIND_ERROR = new  CodeMsg(50101,"参数校验异常：%s");
    public static  CodeMsg ID_EMPTY = new  CodeMsg(50102,"根据ID查询ID为空");
    public static CodeMsg CONDITION_EMPTY = new CodeMsg(50103,"查询参数为空");
    public static CodeMsg CON_EMPTY = new CodeMsg(50104,"查询参数条件为空");
    public static CodeMsg NUMBER_ERROR = new CodeMsg(50105,"参数条件无效");
    public static CodeMsg ENGLISH_ERROR = new CodeMsg(50106,"参数条件中包含无效英文字母");


    private CodeMsg(){}

    private CodeMsg(int code,String msg){
        this.code = code;
        this.msg = msg;
    }

    public  CodeMsg fillArgs(Object... args){
        int code = this.code;
        String message = String.format(this.msg,args);
        return new  CodeMsg(code,message);
    }

    //getter方法
    public int getCode() {
        return code;
    }
    public String getMsg() {
        return msg;
    }
}